home *** CD-ROM | disk | FTP | other *** search
- #define kTrapNumberMask 0x07FF
- #define kUnimplementedTrapWord 0xA89F
-
- static long myGetTrapAddress ( short trapWord ) {
- if ( trapWord & 0x0800 )
- return ( NGetTrapAddress ( trapWord & kTrapNumberMask, ToolTrap ) );
- else
- return ( NGetTrapAddress ( trapWord & kTrapNumberMask, OSTrap ) );
- }
-
- static void mySetTrapAddress ( long proc, short trapWord ) {
- if ( trapWord & 0x0800 )
- NSetTrapAddress ( proc, trapWord & kTrapNumberMask, ToolTrap );
- else
- NSetTrapAddress ( proc, trapWord & kTrapNumberMask, OSTrap );
- }
-
- static Boolean myTrapAvail ( short trapWord ) {
- return ( myGetTrapAddress ( trapWord ) !=
- myGetTrapAddress ( kUnimplementedTrapWord ) );
- }
-
- pascal void main ( void ) {
- ProcessSerialNumber scanPSN, frontPSN;
- ProcessInfoRec pir;
- OSErr err;
- Boolean same;
- long attr;
- char *copyright = "••• This program is © 1991 Pete Gontier, "
- "All Rights Reserved. "
- "Free distribution encouraged. •••";
-
- if ( ! myTrapAvail ( _GestaltDispatch ) ) err = true;
- else {
- if ( ! ( err = Gestalt ( gestaltOSAttr, &attr ) ) )
- if ( ( 1 << gestaltLaunchControl ) & attr ) {
- pir.processInfoLength = sizeof ( ProcessInfoRec );
- pir.processName = nil;
- pir.processAppSpec = nil;
-
- if ( ! ( err = GetFrontProcess ( &frontPSN ) ) ) {
- scanPSN = frontPSN;
- do {
- err = GetNextProcess ( &scanPSN );
-
- if ( err == procNotFound ) {
- scanPSN.lowLongOfPSN = scanPSN.highLongOfPSN = 0;
- if ( err = GetNextProcess ( &scanPSN ) ) break;
- } else if ( err ) break;
-
- if ( ! ( err = SameProcess ( &frontPSN, &scanPSN, &same ) ) ) {
- if ( same ) break;
- if ( ! ( err = GetProcessInformation ( &scanPSN, &pir ) ) )
- if ( ! ( pir.processMode & modeOnlyBackground ) )
- if ( ! ( err = SetFrontProcess ( &scanPSN ) ) ) break;
- }
- } while ( ! err );
- }
- }
- }
- if ( err ) SysBeep ( 10 );
- }